<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" id="score">
<input type="button" id="btn" value="评判">
<div id="output"></div>
<script>
    var scoreObj = document.getElementById('score'); //文本框对象
    var btn = document.getElementById('btn');         //按钮对象
    var output = document.getElementById('output');         //输出对象
    btn.onclick = function () {
        var score = scoreObj.value; //取得文本框的值
        var s = '';
        /*
        if (条件表达式)
            语句
        else
            语句
         */

//        if (score == 10) {
//            s = '满分';
//        }else if (score == 9) {
//            s = '优秀'
//        }else if (score == 8) {
//            s = '良好';
//        }else if (score == 7) {
//            s = '一般'
//        }else if (score == 6) {
//            s = '及格'
//        }else {
//            s = '不及格'
//        }
//


        score = Number(score); //parseInt 12px 12  Number 12px NaN  +score 12px NaN
        score = Math.floor(score);
        console.log(score);
        if (score >10 || score <0 || isNaN(score)) {
            alert('数字应在0-10之间')
        } else if (score == 10){
            s = '满分'
        } else if(score==9){
            s = '优秀'
        } else if (score == 8){
            s = '良好';
        } else if (score == 7){
            s = '一般'
        } else  if (score == 6) {
            s = '及格'
        } else {
            s = '不及格'
        }





/*
        if (score == 10){
            s = '满分';
        } else if (score == 9) {
            s = '优秀';
        } else if (score == 8) {
            s = '优秀';
        }
*/

        output.innerHTML = s;
    }

</script>
</body>
</html>